package com.yuanfeng.activity.controller;

import com.yuanfeng.commoms.constant.CommonStatusEnum;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.ParseTokenUtils;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.vo.user.UserInfoVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName ActivityVoucherInform
 * @Description 商家中心红包优惠券
 * @Author cf
 * @Date 2023/6/25 16:30
 * @Version 1.0
 */
@RestController
@RequestMapping("/activity/voucher/inform")
public class ActivityVoucherInformController extends BaseController{


    /**
     * 查询可报名的优惠券弹框
     * @return
     */
    @PostMapping("/query")
    public ResponseResult queryPlatformVoucher(@RequestBody Map<String,String> param) {
        if(null != param && null != param.get("token")){
            UserInfoVO userInfo = ParseTokenUtils.getUserInfoByToken(param.get("token"));
            if(null != userInfo && null != userInfo.getShopId()){
                return activityVoucherInformService.queryPlatformVoucher();
            }else{
                return ResponseResult.fail(CommonStatusEnum.FAIL.getCode(),BizCodeEnume.INSUFFICIENT_PERMISSIONS.getMsg());
            }
        }else{
            return ResponseResult.fail(CommonStatusEnum.FAIL.getCode(),BizCodeEnume.INSUFFICIENT_PERMISSIONS.getMsg());
        }
    }

}
